package com.abc.server;

import java.sql.ResultSet;
import java.sql.SQLException;



public class SystemParams {

	private DatabaseConnection DatabaseConn=null;
	
	public SystemParams(DatabaseConnection databasecon){
		DatabaseConn=databasecon;
	}
	
	public String getSendSMSUserName() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='Send SMS User Name'");
		results.next();
        return results.getString("paravalue");
        
	}
	
	public String getSendSMSUserPassword() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='Send SMS Password'");
		results.next();
        return results.getString("paravalue");
	}
	
	public String getSendSMSServer() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='Send SMS Server'");
		results.next();
        return results.getString("paravalue");
	}
	
	public int getLastAlertID() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='Last Alert ID'");
		results.next();
        return results.getInt("paravalue");
	}
	
	public void setLastAlertID(int lastalertid) throws SQLException{
		DatabaseConn.sqlUpdate("UPDATE `systemparams` set `paravalue`="+lastalertid+" where `paraname`='Last Alert ID'");
		
	}
	
	public int getSendSMSPort() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='Send SMS Port'");
		results.next();
        return results.getInt("paravalue");
	}
	
	public String getThisOperator() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='This Operator'");
		results.next();
        return results.getString("paravalue");
	}	
	
	public String getOriginationAddress() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='SMS Orig Address'");
		results.next();
        return results.getString("paravalue");
	}
	
	public String getParameter(String parameter) throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='"+parameter+"'");
		results.next();
        return results.getString("paravalue");
	}
	
	public int getSubscriptionValidity() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='Subscription Validity'");
		results.next();
        return results.getInt("paravalue");
	}
	
	public int getAdvertValidity() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='Advert Validity'");
		results.next();
        return results.getInt("paravalue");
	}
	
	public String getSmsHandlerLogFile() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='SmsHandler Log File'");
		results.next();
        return results.getString("paravalue");
	}
	
	public String getSmsHandlerLogLevel() throws SQLException{
		ResultSet results = DatabaseConn.sqlSelect("SELECT `paravalue` from `systemparams` where `paraname`='SmsHandler Log Level'");
		results.next();
        return results.getString("paravalue");
	}
	
	
}
